
(define res  (* (* 3  (+ (*  2  4) (+ 3  5)))  (+ (- 10  7)  6)) )

(define height 2) 

(+ (+ height 40) (- 305 height)) 

(define pi 3.14159) 
(define radius 10) 

(define (square  x)  (*  x  x)) 

(define  circumference  (* 2 pi radius))
(define (area r)   (* pi  (square r) ))

(area radius)

;递归 ，数学归纳法，子问题
(define  
   (fact  n) 
   (cond  ((<= n  1)  1)
          ((>  n  1)  (*  n  (fact  (- n 1))) 
           )))


 
;迭代 - 逼近
 (define (sqrt-iter guess x)
  (if (good-enough? guess x)
      guess
      (sqrt-iter (improve guess x)
                 x)))

(define (improve guess x)
  (average guess (/ x guess)))

(define (average x y)
  (/ (+ x y) 2))

(define (good-enough? guess x)
  (< (abs (- (square guess) x)) 0.001))

(define (mysqrt x)
  (sqrt-iter 1.0 x))

;lambda 表达式
;函数也是普通值
(define (add2 x) (+ 2 x))
(define add2'  (lambda (x) (+ 2 x)))

 ; 神奇的Y组合子/不动点算子
; 实现递归函数的计算
; Y =  \f x. f (x x) \f x. f (x x)
;  Y f  = f (Y f) 
(define Y                  
  (lambda (f)              
    ((lambda (g) (g g))    
     (lambda (g)       
       (f  (lambda a (apply (g g) a))))))) 
 
;; head-recursive factorial
(define fac                 
  (Y (lambda (r)            
       (lambda (x)         
         (if (< x 2)       
             1             
             (* x (r (- x 1))))))))